package org.ft.fileConvert.utils;

import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtMethod;
import javassist.Modifier;

/**
 * Created by Chen Tianzhong in 2022/8/19
 */
public class Test {

    public void testMod_words1(){
        try {
            ClassPool.getDefault().insertClassPath("E:\\temp\\aspose-words-22.3.0-jdk17.jar");
            CtClass zzZJJClass = ClassPool.getDefault().getCtClass("com.aspose.words.zzP6");
            CtMethod methodB = zzZJJClass.getDeclaredMethod("zzWMy");
            methodB.setBody("{return 256;}");
            zzZJJClass.writeFile("/Users/dengbp/Downloads/");
        } catch (Exception e) {
            System.out.println("错误==" + e);
        }
    }
    public void testMod_words2(){
        try{
            Class<?> aClass = Class.forName("com.aspose.words.zzXyu");
            java.lang.reflect.Field zzYAC = aClass.getDeclaredField("zzZXG");
            zzYAC.setAccessible(true);
            java.lang.reflect.Field modifiersField = zzYAC.getClass().getDeclaredField("modifiers");
            modifiersField.setAccessible(true);
            modifiersField.setInt(zzYAC, zzYAC.getModifiers() & ~Modifier.FINAL);
            zzYAC.set(null,new byte[]{76, 73, 67, 69, 78, 83, 69, 68});
        }catch (Exception e){
            System.out.println("apose word 破解异常");
        }

    }

    public static void main(String[] args) {
        new Test().testMod_words2();
    }
}
